package util;

public class Vector {
	public float x;
	public float y;
	public float z;
	
	public Vector(float x, float y, float z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}
 
    public Vector addVectorToVector(Vector v) {
    	this.x += v.x;
    	this.y += v.y;
    	this.z += v.z;
    	return this;
    }
    
    public Vector subtractVectorFromVector(Vector v) {
    	this.x -= v.x;
    	this.y -= v.y;
    	this.z -= v.z;
    	return this;
    }
    
    public Vector rotateXY(float deg) {
    	Vector out = new Vector(0,0,0);
    	float rad = (float) Math.toRadians(deg);
    	float cos = (float) Math.cos(rad);
    	float sin = (float) Math.sin(rad);
    	
    	out.x = cos*x - sin*y;
    	out.y = sin*x + cos*y;
    	out.z = z;
    	
    	return out;
    }
    public Vector rotateXZ(float deg) {
    	Vector out = new Vector(0,0,0);
    	float rad = (float) Math.toRadians(deg);
    	float cos = (float) Math.cos(rad);
    	float sin = (float) Math.sin(rad);
    	
    	out.x = cos*x + sin*z;
    	out.y = y;
    	out.z = -sin*x + cos*z;
    	
    	return out;
    }
    public Vector rotateYZ(float deg) {
    	Vector out = new Vector(0,0,0);
    	float rad = (float) Math.toRadians(deg);
    	float cos = (float) Math.cos(rad);
    	float sin = (float) Math.sin(rad);
    	
    	out.x = x;
    	out.y = cos*y - sin*z;
    	out.z = sin*y + cos*z;
    	
    	return out;
    }
    
    public Vector scale(float s) {
    	return scale(s, s, s);
    }
    public Vector scale(float sX, float sY, float sZ) {
    	return new Vector(x * sX, y * sY, z * sZ);
    }
}
